var o = function () {
};
o.prototype = {
    ctor: function () {
        this._handles = {}, this._msgBuffer = [], this._stop = !1, window.setInterval(this.dispichEvent.bind(this), 1);
    },
    dispichEvent: function () {
        if (1 != this._stop && this._msgBuffer.length > 0) {
            var e = this._msgBuffer[0], t = e.eventName, n = e.data, o = [], i = t;
            for (var a in this._handles) if (a == t) for (var r = 0; r < this._handles[i].length; r++) {
                var s = this._handles[i][r], l = s.callback.call(s.target, n);
                o.push(l);
            }
            return 0 == o.length && cc.warn("NotificationCenter warn", "eventName: " + t + " has no listener! data = " + n),
                this._msgBuffer.splice(0, 1), o;
        }
    },
    emit: function (e, t) {
        var n = {
            eventName: e,
            data: t
        };
        this._msgBuffer.push(n);
    },
    on: function (e, t, n) {
        var o = e;
        this._handles[o] = this._handles[o] || [], this._handles[o].push({
            callback: t,
            target: n
        });
    },
    getHandleByEventName: function (e) {
        var t = e;
        return this._handles && this._handles[t] ? this._handles[t] : null;
    },
    off: function (e, t) {
        var n = e;
        this._handles[n] = this._handles[n] || [];
        for (var o = this._handles[n].length - 1; o >= 0; o--) {
            this._handles[n][o].target == t && this._handles[n].splice(o, 1);
        }
    },
    offAll: function (e) {
        for (var t in this._handles) {
            this.off(t, e);
        }
    },
    start: function () {
        this._stop = !1;
    },
    stop: function () {
        this._stop = !0;
    }
};
module.exports = o
